#include <stdlib.h>
#include <boost/lexical_cast.hpp>
#include <string>
#include <vlc/vlc.h>

using namespace std;

class Video_vlc
{
	debug dbg;

	string to_string(int i)
	{
		return boost::lexical_cast<string>(i);	
	}
public:
	Video_vlc(string video,int x, int y, int w, int h, int z, int ts, int te)
	{
	  try
	  {
		//string s = "cvlc --no-osd --width=" + to_string(w) + " --height=" + to_string(h) + " " + video + " >> log/video.log  2>&1";
  		//int i=system (s.c_str());
		libvlc_instance_t * inst;
		libvlc_media_player_t *mp;
		libvlc_media_t *m;

		/* Load the VLC engine */
		inst = libvlc_new (0, NULL);

		/* Create a new item */
		/*m = libvlc_media_new_path (inst, "http://mycool.movie.com/test.mov");*/
		m = libvlc_media_new_path (inst, video.c_str());

		/* Create a media player playing environement */
		mp = libvlc_media_player_new_from_media (m);

		/* No need to keep the media now */
		libvlc_media_release (m);

		/* play the media_player */
		libvlc_media_player_play (mp);

     		sleep (2); /* Let it play a bit */

		/* Stop playing */
		libvlc_media_player_stop (mp);

		/* Free the media_player */
		libvlc_media_player_release (mp);

		libvlc_release (inst);
	  }
    	  catch (exception &e)
	  {
		dbg.log(__PRETTY_FUNCTION__,"Error: " + boost::lexical_cast<string>(e.what()));
	  }
	}

	~Video_vlc()
	{
	}
	
};

class Sound_vlc
{
	debug dbg;
	string to_string(int i)
	{
		return boost::lexical_cast<string>(i);	
	}
public:
	Sound_vlc(string sound,int x, int y, int w, int h, int z, int ts, int te)
	{
	  try
	  {
		//string s = "cvlc --no-osd --width=" + to_string(w) + " --height=" + to_string(h) + " " + sound + " >> log/sound.log  2>&1";
  		//int i=system (s.c_str());
		libvlc_instance_t * inst;
		libvlc_media_player_t *mp;
		libvlc_media_t *m;

		/* Load the VLC engine */
		inst = libvlc_new (0, NULL);

		/* Create a new item */
		/*m = libvlc_media_new_path (inst, "http://mycool.movie.com/test.mov");*/
		m = libvlc_media_new_path (inst, sound.c_str());

		/* Create a media player playing environement */
		mp = libvlc_media_player_new_from_media (m);

		/* No need to keep the media now */
		libvlc_media_release (m);

		/* play the media_player */
		libvlc_media_player_play (mp);

     		sleep (2); /* Let it play a bit */

		/* Stop playing */
		libvlc_media_player_stop (mp);

		/* Free the media_player */
		libvlc_media_player_release (mp);

		libvlc_release (inst);
	  }
    	  catch (exception &e)
	  {
		dbg.log(__PRETTY_FUNCTION__,"Error: " + boost::lexical_cast<string>(e.what()));
	  }

	}

	~Sound_vlc()
	{
	}
};
